package bt19022014_congty;

import java.util.List;

public class NhanVien {
	private String msNV;
	private String ten;
	private DiaChi diaChi;
	private BangLuong bangLuong;
	private List<NguoiThan> dsNguoiThan;
	
	//Khoi tao ko tham so
	public NhanVien(){
		setMsNV(null);
		ten = null;
		diaChi = new DiaChi();
		bangLuong = new BangLuong();
		dsNguoiThan = null;
	}
	
	//Khoi tao co tham so
	public NhanVien(String msNV, String ten, DiaChi diaChi, BangLuong bangLuong, List<NguoiThan> dsNguoiThan){
		this.setMsNV(msNV);
		this.ten = ten;
		this.diaChi = diaChi;
		this.bangLuong = bangLuong;
		this.dsNguoiThan = dsNguoiThan;
	}
	
	//Kiem tra ma so nhan vien co trung` hay ko
	public boolean ktraMSNV(String msNV){
		return this.getMsNV().equals(msNV);
	}
	
	public void setMsNV(String msNV) {
		this.msNV = msNV;
	}

	public String getMsNV() {
		return msNV;
	}
	
	//Goi phuong thuc tinh luong trong bang luong de tinh luong cho Nhan vien hien tai
	public double tinhLuong(){
		return this.bangLuong.tinhLuong();
	}
	
	//Phuong thuc dem so nguoi than cua NV hien tai
	public int demNgThan(){
		int dem = 0;
		for(NguoiThan a : dsNguoiThan){
			dem++;
		}
		return dem;
	}
	
	//Phuong thuc kiem tra dia chi NV hien tai co trung voi dia chi can kiem tra hay ko
	public boolean ktraDiaChiNV(String diaChi){
		return this.diaChi.equals(diaChi);
	}
	
	//Phuong thuc kiem tra ten nguoi than cua nhan vien co chua ten can kiem tra hay ko
	public boolean ktraTenNgThan(String ten){
		for (NguoiThan a : dsNguoiThan){
			return a.getTen().equals(ten);
		}
		return false;
	}
	
	//Phuong thuc so sanh luong NV hien tai co nho hon so voi voi muc luong duoc nhap vao hay ko
	public boolean ssanhLuong(double luong){
		return this.bangLuong.tinhLuong()< luong;
	}
	
	//Phuong thuc in thong tin NV hien tai
	public void inNhanVien(){
		System.out.println("Ma so nhan vien: "+msNV+" | Ho va ten: "+ten);
		System.out.println("Dia chi: "+ this.diaChi.getDiaChi());
		System.out.println("Luong hien tai: "+this.bangLuong.tinhLuong());
		System.out.println("===Nguoi Than===");
		for (NguoiThan a : dsNguoiThan){
			System.out.println("+"+a.getNguoiThan());
		}
		
	}

}
